#coding:utf-8
import unittest
import HTMLTestRunner
import time


def createsuite():
    testunit = unittest.TestSuite()

    #查找用例路径
    test_dir = "C:\\Users\\Administrator\\Desktop\\BF_interface\\"

    discover = unittest.defaultTestLoader.discover(test_dir,
                                                   pattern="test*.py",top_level_dir=None)
    #将过滤test*的文件，添加到套件
    for test_case in discover:
        print test_case
        testunit.addTests(test_case)
    return testunit

now = time.strftime("%Y-%m-%d %H_%M_%S")
filename = 'C:\\Users\\Administrator\\Desktop\\BF_interface\\'+now+'result.html'
fp = file(filename, 'wb')
runner =HTMLTestRunner.HTMLTestRunner(
    stream=fp,
    title=u'供应链金融平台第三方仓储对接接口测试报告：',
    description=u'用例执行情况：')
    
if __name__ == '__main__':
    alltestnames = createsuite()
    runner.run(alltestnames)
    fp.close()
